extends "../calxJS_Hide/calxJS_Hide.gd"
func _init():
	pass
func _extInit():
	._extInit()
	chaName = "圣麟"                   # 角色的名称
	attCoe.atkRan = 3                 # 攻击距离
	attCoe.maxHp = 5                  # 最大生命（每点代表112.5基础数值，取整数，下同）
	attCoe.atk = 8                    # 攻击力（每点代表8.5）
	attCoe.mgiAtk = 3                 # 魔法攻击（每点代表13.7）
	attCoe.def = 4                    # 物理防御（每点代表15）
	attCoe.mgiDef = 4                 # 魔法防御（每点代表16.6）
	atkEff = "atk_dang" 
	xb = "王"
	lv = 3   
	addSkillTxt("[万界必破]万界必破之力攻击目标单体，造成220%王系物理伤害并使目标降低100点双防3秒\n若目标<麻痹>了，则清空目标增益[CD:13]")
	addSkillTxt("[君临天下]激发体内君临天下之力，提升自身双攻双防双速10%，最高60%，20%概率额外提升一次\n但会<眩晕>2秒[CD:11]")
	addSkillTxt("[雷光裁决]从天而降的雷电攻击目标单体，造成145%光系物理伤害，并击退目标\n若击退时目标身后有敌军或墙壁，则<眩晕>5秒[CD:8]")
	addCdSkill("wjbp",13)
	addCdSkill("jltx",11)
	addCdSkill("lgcj",8)

func _castCdSkill(id):
	._castCdSkill(id)
	if id == "wjbp":
		var eff = sys.newEff("numHit", position, false, 1)
		eff.setText("万界必破", "#FF0099")
		eff.anim.set_speed_scale(0.2)
		typeHurtCha(aiCha,att.atk*2.2,Chara.HurtType.PHY,Chara.AtkType.SKILL)
		aiCha.addBuff(wjbp1.new(3))
		var buff:Buff = aiCha.hasBuff("mabi")
		if buff != null:
			for j in buffs:
				if j.isNegetive and j.get("dispelable") != true:
					j.isDel = true	
	if id == "jltx":
		var eff = sys.newEff("numHit", position, false, 1)
		eff.setText("君临天下", "#FF0099")
		eff.anim.set_speed_scale(0.2)
		var b = hasBuff("wugong1")
		var b1 = hasBuff("mogong1")
		var b2 = hasBuff("wukang1")
		var b3 = hasBuff("mokang1")
		var b4 = hasBuff("gongsu1")
		var b5 = hasBuff("lengque1")
		if b == null:
			addBuff(bf.wugong1.new())
		elif b.att.atkL < 0.6:
			b.att.atkL += 0.1
		if b1 == null:
			addBuff(bf.mogong1.new())
		elif b1.att.mgiAtkL < 0.6:
			b1.att.mgiAtkL += 0.1
		if b2 == null:
			addBuff(bf.wukang1.new())
		elif b2.att.defL < 0.6:
			b2.att.defL += 0.1
		if b3 == null:
			addBuff(bf.mokang1.new())
		elif b3.att.mgiDefL < 0.6:
			b3.att.mgiDefL += 0.1
		if b4 == null:
			addBuff(bf.gongsu1.new())
		elif b4.att.spd < 0.6:
			b4.att.spd += 0.1
		if b5 == null:
			addBuff(bf.lengque1.new())
		elif b5.att.cd < 0.6:
			b5.att.cd += 0.1
		if sys.rndPer(20):
			if b == null:
				addBuff(bf.wugong1.new())
			elif b.att.atkL < 0.6:
				b.att.atkL += 0.1
			if b1 == null:
				addBuff(bf.mogong1.new())
			elif b1.att.mgiAtkL < 0.6:
				b1.att.mgiAtkL += 0.1
			if b2 == null:
				addBuff(bf.wukang1.new())
			elif b2.att.defL < 0.6:
				b2.att.defL += 0.1
			if b3 == null:
				addBuff(bf.mokang1.new())
			elif b3.att.mgiDefL < 0.6:
				b3.att.mgiDefL += 0.1
			if b4 == null:
				addBuff(bf.gongsu1.new())
			elif b4.att.spd < 0.6:
				b4.att.spd += 0.1
			if b5 == null:
				addBuff(bf.lengque1.new())
			elif b5.att.cd < 0.6:
				b5.att.cd += 0.1
			addBuff(bf.jiyun.new(2))
	if id == "lgcj":
		var eff1 = sys.newEff("numHit", position, false, 1)
		eff1.setText("雷光裁决", "#FF0099")
		eff1.anim.set_speed_scale(0.2)
		typeHurtCha(aiCha,att.atk*1.45,Chara.HurtType.PHY,Chara.AtkType.SKILL)
		jiTui(self,aiCha,5)
		

func jiTui(me, aiCha, time):
	var pos:Vector2 = Vector2(0,0)
	var isYun = false
	if me.cell.y > aiCha.cell.y && me.cell.x == aiCha.cell.x:#在自己的上格
		pos = aiCha.cell + Vector2(0, -1)
		if aiCha.cell.y == 0:
			isYun = true
	if me.cell.y < aiCha.cell.y && me.cell.x == aiCha.cell.x:#在自己的下格
		pos = aiCha.cell + Vector2(0, 1)
		if aiCha.cell.y == 4:
			isYun = true
	if me.cell.x < aiCha.cell.x:#在自己的左格
		pos = aiCha.cell + Vector2(1, 0)
		if aiCha.cell.x == 7:
			isYun = true
	if me.cell.x > aiCha.cell.x:#在自己的右格
		pos = aiCha.cell + Vector2(-1, 0)
		if aiCha.cell.y == 4:
			isYun = true
	var t = me.matCha(pos)
	#如果身后有其它单位，或地图边界，就晕眩
	if t != null || isYun:
		aiCha.addBuff(bf.jiyun.new(time))
	aiCha.setCell(pos)


class wjbp1:
	extends Buff
	func _init(lv = 1):
		attInit()
		var dispelable = false
		isNegetive=true
		life = lv
		id = "wjbp1"	
		att.def -= 100
		att.mgiDef -= 100